package leetcodecompetition.D355;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: Siantar
 * @Date: 2023-07-23-10:37
 * @Description: 1.0
 */
public class T6921 {
    public List<String> splitWordsBySeparator(List<String> words, char separator) {
        List<String> list = new ArrayList<>();
        for (String s : words) {
            list.addAll(split(s, separator));
        }
        return list;
    }

    public List<String> split(String s, char se) {
        int i = 0;
        List<String> list = new ArrayList<>();
        while (i < s.length()) {
            if (s.charAt(i) == se) {
                i++;
                continue;
            }
            StringBuilder ss = new StringBuilder();
            while (i < s.length() && s.charAt(i) != se) {
                ss.append(s.charAt(i));
                i++;
            }
            list.add(ss.toString());
        }
        return list;
    }

    //    ,"four.five","six"[]
//            "."
    @Test
    public void test() {
        splitWordsBySeparator(new ArrayList<String>(){{add("one.two.three");}},'.');
    }
}
